package com.service.basic.support;

import java.io.Serializable;
import java.util.List;

import com.dao.basic.IModuleTypesDao;
import com.pojo.basic.ModuleTypes;
import com.service.basic.IModuleTypesService;
import com.vo.basic.ModuleTypesVo;

public class ModuleTypesService implements IModuleTypesService {
	
	private IModuleTypesDao moduleTypesDao;

	//setter getter property
	
	public void setModuleTypesDao(IModuleTypesDao moduleTypesDao) {
		this.moduleTypesDao = moduleTypesDao;
	}

	//method
	
	@Deprecated
	public ModuleTypes findRootModuleTypes() {
		return moduleTypesDao.findRootModuleTypes();
	}

	public List<ModuleTypes> findChildModuleTypes(Integer pid) {
		return moduleTypesDao.findChildModuleTypes(pid);
	}

	public Serializable addModuleTypes(ModuleTypesVo mtv) {
		Integer id = 0;
		try{
			ModuleTypes mt = new ModuleTypes();
			mt.setPid(mtv.getPid());
			mt.setName(mtv.getName());
			mt.setRemark(mtv.getRemark());
			if(mtv.getUrl()==null||mtv.getUrl().equals("")){
				mt.setUrl("#");
			}
			id = (Integer) moduleTypesDao.addModuleTypes(mt);
		}catch(Exception e){
			return -1;
		}
		return id;
	}

}
